<template>
  <!--
    el-dropdown
        默认:默认展示内容
        具名:dropdown
 -->

  <el-dropdown>
    <span>
      <svg-icon class="icon" icon-class="language" />
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item :disabled="$i18n.locale==='zh'" @click.native="changeLang('zh')">中文</el-dropdown-item>
        <el-dropdown-item :disabled="$i18n.locale==='en'" @click.native="changeLang('en')">English</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
<script>
import jsCookie from 'js-cookie'
export default {
  name: 'HmLang', // 1:keep-alive  include=''  2:组件注册时可以用上    3：插件调试时使用
  methods: {
    changeLang(str) {
      this.$i18n.locale = str
      jsCookie.set('lang', str)
      // 刷新网站
      this.$router.go(0)
    }
  }
}
</script>
<style lang="scss" scoped>
.icon{
    color:#fff;
    font-size: 24px;
}
</style>
